//
//  JBTabBarController.swift
//  JBSina
//
//  Created by apple on 16/11/25.
//  Copyright © 2016年 itheima. All rights reserved.
//

import UIKit

class JBTabBarController: UITabBarController {
    
    
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        let tabBar = JBTarbar()
        self.setValue(tabBar, forKey: "tabar")
        
        tabBar.closure = {
            print("控制器实现跳转")
        }
        
        }
    
    
    
    //为TabBar添加NavicationController
    func addChildViewController(_ childController: UIViewController, image:String,title:String ) {
        childController.title = title
        
        childController.tabBarItem.image = UIImage.init(named: image)
        
        childController.tabBarItem.selectedImage = UIImage(named: "\(image)_hightlighted")?.withRenderingMode(UIImageRenderingMode.alwaysOriginal)
        
        childController.tabBarItem.setTitleTextAttributes([NSFontAttributeName: UIFont.systemFont(ofSize: 15),NSForegroundColorAttributeName: UIColor.orange],for: UIControlState.selected)
        
        let nav = UINavigationController.init(rootViewController: childController)
        
        addChildViewController(nav)
        
        
    }
    

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    

  
}
